{%extends file="base_content.html"%}
{%block name="breadcrumb"%}
<li class="active">系统用户管理</li>
{%/block%}

{%block name="content"%}

<div class="page-header">

    <div class="row">
        <div class="col-xs-1"  style="min-width: 80px">
            <a href="index.php?c=sys_user&m=add" class="btn btn-success btn-sm">
                <i class="ace-icon fa fa-plus bigger-110"></i>新建
            </a>
        </div>

        <div class="col-xs-8">
            <form class="form-inline" style="width: 300px" method="post">

                <div class="input-group">
                    <input type="text" class="form-control search-query" name="keywords" placeholder="姓名">
                        <span class="input-group-btn">
                            <button type="submit" class="btn btn-purple btn-sm">
                                查询
                                <i class="ace-icon fa fa-search icon-on-right bigger-110"></i>
                            </button>
                        </span>
                </div>
            </form>
        </div>
    </div>


</div>

<table id="sample-table-2" class="table table-striped table-bordered table-hover">
    <thead>
    <tr>


        <th>账号</th>
        <th>姓名</th>
        <th>邮箱</th>
        <th>用户组</th>
        <th>开启</th>
        <th style="width: 70px">操作</th>
    </tr>
    </thead>

    <tbody>
    {%foreach from=$list item=value%}
    <tr>

        <td>{%$value.username%}</td>
        <td>{%$value.truename%}</td>
        <td>{%$value.email%}</td>
        <td>{%$value.group_name%}</td>
        <td><label>
            <input name="flag_valid" id="flag_valid" class="ace ace-switch ace-switch-6" type="checkbox"
                   onchange="updateStatus('{%$value.id%}',this)"
            {%if $value.flag_valid|default:''==1%}checked{%/if%}  value="1"/>
            <span class="lbl"></span>
        </label></td>


        <td>
            <div class="action-buttons">


                <a class="green" href="index.php?c=sys_user&m=edit&id={%$value.id%}">
                    <i class="ace-icon fa fa-pencil bigger-130"></i>
                </a>


                <div class="inline position-relative">
                    <a href="#" class="red dropdown-toggle" data-toggle="dropdown" data-position="auto">
                        <i class="ace-icon fa fa-trash-o icon-only bigger-130"></i>
                    </a>

                    <ul class="dropdown-menu dropdown-only-icon dropdown-yellow dropdown-menu-right dropdown-caret dropdown-close">
                        <li>
                            <a href="javascript:void(0)" onclick="deleteEntity('{%$value.id%}',this)"
                               class="tooltip-error" data-rel="tooltip" title="" data-original-title="Delete">
                                <span class="red">
                                    <i class="ace-icon fa fa-trash-o bigger-130"></i>
                                </span>
                            </a>
                        </li>
                    </ul>
                </div>


            </div>
        </td>
    </tr>
    {%foreachelse%}
    {%include file="inc_gritter.html"%}
    {%/foreach%}
    </tbody>
</table>
{%$pagerbar%}
{%/block%}

{%block name="js"%}
<script>
    function deleteEntity(id,btn){


        $.get("index.php?c=sys_user&m=delete&id="+id,function(r){
            if(r=='{%$smarty.const.STATUS_SUCCESS%}'){
                tr_row = btn.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode
                list_table=tr_row.parentNode;
                list_table.removeChild(tr_row);
            }else{
                alert("删除失败");
            }
        });

    }

    function updateStatus(id,cb){

        $.get("index.php?c=sys_user&m=status&id="+id+"&status="+(cb.checked?1:0),function(r){
            if(r=='{%$smarty.const.STATUS_SUCCESS%}'){

            }else{
                if(cb.checked){
                    cb.checked = false;
                }else{
                    cb.checked = true;
                }
            }
        });

    }
</script>
{%/block%}